//订单管理-订单售后列表
App.util.ns('Admin.Orders.AfterSale');
App.pages.add((function(){
    var NS = Admin.Orders.AfterSale;
    var page = new App.Page({
        name: 'orders/aftersale/index'
    });
    //页面初始化
    page.initStack.add('dataTable', function(){
        //面包屑导航
        this.setBreadcrumb([{
            icon: '<i class="fa fa-dollar"></i>',
            content: '订单管理'
        }, {
            content: '订单售后'
        }]);
        this.dataTable = new App.DataTable({
            baseUrl: '/admin/orders/aftersale',
            dataUrl: 'lists',
            table: {
                id: 'id',
                main: 0,
                //showId: false,
                columns: App.util.copy(NS.Conf.columns)
            },
            filter: [
                //{type: 'keywords'},
                {type: 'timeRange'},
                {type: 'select', name: 'type', title: '类型', width: '80px', items: [
                    [1, '换货'],
                    [2, '退货'],
                    [3, '维修']
                ]},
                {type: 'select', name: 'state', title: '退款状态', width: '80px', items: [
                    [0, '未退款'],
                    [1, '已退款']
                ]},
                {type: 'select', name: 'status', title: '审核状态', width: '80px', items: [
                    [0, '申请'],
                    [1, '审核通过'],
                    [2, '审核驳回']
                ]}
            ],
            menu: [
                {parent: 'view', permission: 'op:admin.orders.aftersale.detail'},
                {type: 'inline', permission: 'op:admin.orders.aftersale.wxrefund', name: '退款',
                    operation: {type: 'change', url: 'wxrefund'},
                    conditions: [['status', '1'],['state', '0'],['type', '2']],
                },
                //{parent: 'edit', permission: 'op:admin.experience.experience.update'},
                {
                    type: 'inline',
                    name: '换货运单',
                    permission: 'gp:admin/orders/aftersale',
                    conditions: [['type', '1'],['status', '1']],
                    operation: function(dataTable, aftersale){
                        var win = dataTable.wins.get('deliversno');
                        win.form.change({
                            order_id: aftersale.order_id,
                        });
                        win.show();
                    }
                },
                {parent: 'drop', permission: 'op:admin.orders.aftersale.delete'},
                {type: 'inline', permission: 'op:admin.orders.aftersale.adopt', name: '通过', operation: {type: 'change', url: 'adopt'}, conditions: [['status', '0']]},
                {type: 'inline', permission: 'op:admin.orders.aftersale.reject', name: '驳回', operation: {type: 'change', url: 'reject'}, conditions: [['status', '0']]},
                {parent: 'multiDrop', permission: 'op:admin.orders.aftersale.multiDelete'},
                {parent: 'oplog', permission: 'op:admin.orders.aftersale.getOpLogs'}
            ],
            detail: {
                form: {
                    items: App.util.copy(NS.Conf.form)
                }
            },
            after: function(dataTable){
                dataTable.wins.add(new NS.Deliversno(dataTable), 'deliversno');
            }
        }, page);
        this.dataTable.fix(this.contentContainer);
        this.dataTable.loadData();
    });
    //页面刷新
    page.refreshStack.add('dataTable', function(){
        this.dataTable.loadData(true);
    });
    //页面销毁
    page.destroyStack.add('dataTable', function(){
        this.dataTable.destroy();
    });
    return page;
})());